package com.aaa.service.impl;

import com.aaa.dao.TeacherWebDao;
import com.aaa.service.TeacherWebService;
import com.eig.common.entity.course.Teacher;
import com.eig.common.vo.Result;
import com.hone.honewed.uilt.Sendmss;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Random;

/**
 * @author ：StudentLsj（李世界）
 * @date ：Created in 2023/02/01 上午 11:12
 * @description：
 * @modified By：
 * @version:
 */
@Service
public class TeacherWebServiceImpl implements TeacherWebService {

    @Resource
    private TeacherWebDao teacherWebDao;

    @Resource
    Sendmss sendmss;

    @Override
    public Result getYanZhengMa(String member) {
        Random random = new Random();
        String result="";
        for (int i=0;i<6;i++)
        {
            result+=random.nextInt(10);
        }

        try {
            sendmss.sendSms(member,result);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return new Result(2000,"发送成功",result);
    }

    @Override
    public Result addTeacherWeb(Teacher teacher) {
        teacher.setIntro("哈哈哈来了来了");
        teacher.setGmt_create(new Date());
        teacher.setGmt_modified(new Date());
        teacher.setStatus("0");
        teacher.setIs_deleted(0);
        teacher.setSort(0);
        int insert = teacherWebDao.insert(teacher);

        return new Result(2000,"添加成功");
    }


}
